package cn.swu.lyx.homework2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class UserActivity : AppCompatActivity() {
    val userList= arrayListOf<User>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.fragment_user_management)
        // 初始化数据
        initUser()
        val recyclerView=findViewById<RecyclerView>(R.id.recyclerView)
        recyclerView.layoutManager=LinearLayoutManager(this)
        recyclerView.adapter=UserAdapter(userList)

    }

    private fun initUser(){
        repeat(10){
            userList.add(
                User().apply {
                    image=R.drawable.user
                    ID="易只羊"
                    name="千禧"
                    sex="男"
                    tel="13688888888"
                    type="管理员"
                }
            )
            userList.add(
                User().apply {
                    image=R.drawable.user
                    ID="易只猪"
                    name="千欢"
                    sex="女"
                    tel="13688888888"
                    type="管理员"
                }
            )

        }
    }
}